package com.janwen.j2se.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * JDK proxy base on Interface
 * @author janwen
 * Jun 18, 2012
 */
public class LogProxyHanler implements InvocationHandler{

	public LogProxyHanler(Object targe) {
		this.target = targe;
	}
	private Object target;
	
	static final Log logger = LogFactory.getLog(LogProxyHanler.class);
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		logger.info("ForumService method begin log");
		Object obj = method.invoke(target, args);
		logger.info("ForumService method end log");
		return obj;
	}

}
